/*
 * This file is part of aion-emu <aion-emu.com>.
 *
 *  aion-emu is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  aion-emu is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with aion-emu.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionemu.gameserver.model.gameobjects.stats;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;

/**
 * @author xavier
 * @author ATracer
 *
 */
@XmlType(name = "StatEnum")
@XmlEnum
public enum StatEnum
{
	//	None = 0,
	//	FireResistance = 15,
	//	HP = 18,
	//	MP = 20,
	//	FlightTime = 23,
	//	Attack = 25,
	//	PhysicalDefense = 26,
	//	MagicalAttack = 27,
	//	MagicalRes = 28,
	//	AttackSpeed = 29, //%
	//	Accuracy = 30,
	//	Evasion = 31,
	//	Parry = 32,
	//	Block = 33,
	//	PhysicalCrit = 34,
	//	Speed = 36, // %
	//	FlightSpeed = 37, // %
	//	MagicalCrit = 40,
	//	Concentration = 41,
	//	MagicPower = 104,
	//	MagicalAccuracy = 105,
	//	Knowledge = 106,
	//	Agility = 107,
	//	Hate = 109
	MAXDP(0, "maxdp"),
	MAXHP(18, "maxhp"),
	MAXMP(20, "maxmp"),

	AGILITY(107, "agility", true),
	BLOCK(33, "block", true),
	EVASION(31, "dodge", true),
	CONCENTRATION(41, "concentration"),
	WILL(0, "will", true),
	HEALTH(0, "health", true),
	ACCURACY(0, "accuracy", true),
	KNOWLEDGE(106, "knowledge", true),
	PARRY(32, "parry", true),
	POWER(0, "strength", true),
	SPEED(36, "speed", true),

	ATTACK_RANGE(0, "attackrange", true),
	ATTACK_SPEED(29, "attackdelay", -1, true),
	PHYSICAL_ATTACK(25, "phyattack", true),
	PHYSICAL_ATTACK_MAIN_HAND(25, "phyattack", true),
	PHYSICAL_ATTACK_OFF_HAND(25, "phyattack", true),
	
	PHYSICAL_ACCURACY(30, "hitaccuracy", true),
	PHYSICAL_ACCURACY_MAIN_HAND(30, "hitaccuracy", true),
	PHYSICAL_ACCURACY_OFF_HAND(30, "hitaccuracy", true),
	
	PHYSICAL_CRITICAL(34, "critical", true),
	PHYSICAL_CRITICAL_MAIN_HAND(34, "critical", true),
	PHYSICAL_CRITICAL_OFF_HAND(34, "critical", true),
	PHYSICAL_DEFENSE(26, "physicaldefend", true),
	CRITICAL_RESIST(0, "physicalcriticalreducerate", true),

	MAGICAL_ATTACK(27, "magicalattack", true),
	MAGICAL_ACCURACY(105, "magicalhitaccuracy", true),
	MAGICAL_CRITICAL(40, "magicalcritical", true),
	MAGICAL_RESIST(28, "magicalresist", true),
	IS_MAGICAL_ATTACK(0, "ismagicalattack", true),

	EARTH_RESISTANCE(0, "elementaldefendearth", true),
	FIRE_RESISTANCE(15, "elementaldefendfire", true),
	WIND_RESISTANCE(0, "elementaldefendair", true),
	WATER_RESISTANCE(0, "elementaldefendwater", true),
	DARK_RESISTANCE(0, "elementaldefenddark"),
	LIGHT_RESISTANCE(0, "elementaldefendlight"),
	BOOST_MAGICAL_SKILL(104, "magicalskillboost", true),
	BOOST_CASTING_TIME(0, "boostcastingtime", true),
	BOOST_CASTING_TIME_SUMMON(0, "boostcastingtimesummon", true),
    BOOST_CASTING_TIME_TRAP(0, "boostcastingtimetrap", true),
    BOOST_CASTING_TIME_SUMMONHOMING(0, "boostcastingtimesummonhoming", true),
    BOOST_CASTING_TIME_ATTACK(0, "boostcastingtimeattack", true),
    BOOST_CASTING_TIME_HEAL(0, "boostcastingtimeheal", true),
	BOOST_HATE(109, "boosthate"),
	BOOST_HEAL(0, "boostheal", true),
	BOOST_SKILL_COST(0, "boostskillcost"),
	FLY_TIME(23, "maxfp"),
	FLY_SPEED(37, "flyspeed", true),

	PVP_ATTACK_RATIO(0, "pvpattackratio"),
	PVP_DEFEND_RATIO(0, "pvpdefendratio"),

	DAMAGE_REDUCE(0, "damagereduce"),

	BLEED_RESISTANCE(0, "arbleed"),
	BLIND_RESISTANCE(0, "arblind"),
	CHARM_RESISTANCE(0, "archarm"),
	CONFUSE_RESISTANCE(0, "arconfuse"),
	CURSE_RESISTANCE(0, "arcurse"),
	DISEASE_RESISTANCE(0, "ardisease"),
	FEAR_RESISTANCE(0, "arfear"),
	OPENAREIAL_RESISTANCE(0, "aropenareial"),
	PARALYZE_RESISTANCE(0, "arparalyze"),
	PERIFICATION_RESISTANCE(0, "arperification"),
	POISON_RESISTANCE(0, "arpoison"),
	ROOT_RESISTANCE(0, "arroot"),
	SILENCE_RESISTANCE(0, "arsilence"),
	SLEEP_RESISTANCE(0, "arsleep"),
	SLOW_RESISTANCE(0, "arslow"),
	SNARE_RESISTANCE(0, "arsnare"),
	SPIN_RESISTANCE(0, "arspin"),
	STAGGER_RESISTANCE(0, "arstagger"),
	STUMBLE_RESISTANCE(0, "arstumble"),
	STUN_RESISTANCE(0, "arstun"),

	REGEN_MP(0, "mpregen"),
	REGEN_HP(0, "hpregen"),

	/**
	 * New/Strange
	 */
	REGEN_FP(0, "fpregen"),
	STAGGER_BOOST(0, "stagger_arp"),
	STUMBLE_BOOST(0, "stumble_arp"),
	STUN_BOOST(0, "stun_arp"),
	HEAL_BOOST(0, "healskillboost"),
	ALLRESIST(0, "allresist"),
	STUNLIKE_RESISTANCE(0, "arstunlike"),
	MAGICAL_CRITICAL_RESIST(0, "magicalcriticalresist", true),
	MAGICAL_CRITICAL_DAMAGE_REDUCE(0, "magicalcriticaldamagereduce", true),
	PHYSICAL_CRITICAL_RESIST(0, "physicalcriticalresist", true),
	PHYSICAL_CRITICAL_DAMAGE_REDUCE(0, "physicalcriticalreducerate", true),
	ERFIRE(0, "erfire"),
	ERAIR(0, "erair"),
	EREARTH(0, "erearth"),
	ERWATER(0, "erwater"),
	ABNORMAL_RESISTANCE_ALL(0, "abnormal_resistance_all"),
	MAGICAL_DEFEND(0, "magical_defend"),
	ALLPARA(0, "allpara"),
	KNOWIL(0, "knowil"),
	AGIDEX(0, "agidex"),
	STRVIT(0, "strvit");

	private String	name;
	private boolean	updateStat;
	private int		sign;

	private int		itemStoneMask;

	private StatEnum(int stoneMask, String name)
	{
		this(stoneMask, name, 1, false);
	}

	private StatEnum(int stoneMask, String name, boolean replace)
	{
		this(stoneMask, name, 1, replace);
	}

	private StatEnum(int stoneMask, String name, int sign)
	{
		this(stoneMask, name, sign, false);
	}

	private StatEnum(int stoneMask, String name, int sign, boolean updateStat)
	{
		this.itemStoneMask = stoneMask;
		this.name = name;
		this.updateStat = updateStat;
		this.sign = sign;
	}

	public String getName()
	{
		return name;
	}

	public int getSign()
	{
		return sign;
	}

	/**
	 * @return the itemStoneMask
	 */
	public int getItemStoneMask()
	{
		return itemStoneMask;
	}

	public static StatEnum find(String name)
	{
		for (StatEnum sEnum : values())
		{
			if (sEnum.getName().toLowerCase().equals(name.toLowerCase()))
			{
				return sEnum;
			}
		}
		throw new IllegalArgumentException("Cannot find StatEnum for: " + name);
	}

	/**
	 *  Used to find specific StatEnum by its item stone mask
	 *   
	 * @param mask
	 * @return StatEnum
	 */
	public static StatEnum findByItemStoneMask(int mask)
	{
		for (StatEnum sEnum : values())
		{
			if (sEnum.getItemStoneMask() == mask)
			{
				return sEnum;
			}
		}
		throw new IllegalArgumentException("Cannot find StatEnum for stone mask: " + mask);
	}

	public boolean isupdateStat()
	{
		return updateStat;
	}
}
